package kz.sdu.javaee.techsupport;

import com.vaadin.Application;
import kz.sdu.javaee.techsupport.gui.AdminWindow;
import kz.sdu.javaee.techsupport.ws.UserDTO;
import kz.sdu.javaee.techsupport.gui.LoginWindow;

/**
 * Created by IntelliJ IDEA.
 * User: true
 * Date: 4/26/12
 * Time: 1:09 AM
 * To change this template use File | Settings | File Templates.
 */
public class TeApplication extends Application {

    private UserDTO user;

    public UserDTO getUser() {
        return user;
    }

    public void setUser(UserDTO user) {
        this.user = user;
    }

    @Override
    public void init() {
        setMainWindow(new LoginWindow(this));
    }

    public void showMainWindow(UserDTO user) {
        this.setUser(user);
        if(user.getUserType().getUserType().equals("admin")){
            this.removeWindow(this.getMainWindow());
            AdminWindow adminWindow = new AdminWindow(this);
            setMainWindow(adminWindow);
            addWindow(adminWindow);
        }
    }
}
